package mini.hug;

import owg.util.Calc;
import owg.util.opengl.ColorF;
import hubol.Entity;

public class Exhaust extends Entity{
	private final Shake s = Hug.me.shake();
	private double goal = .2 + Calc.random(.3);
	private int life = 0;
	
	public Exhaust(double x, double y, double mult) {
		super(x, y);
		sprite = Hug.FLOWER;
		imageSingle = (float)Calc.random(3);
		imageSpeed = 0;
		hspeed = (1 + Calc.random(.8)) * mult;
		vspeed = Calc.rangedRandom(2);
		setDepth(-899);
		
		angle = (float)Calc.random(360);
		
		xscale = (float)Calc.random(.2);
	}
	
	public Exhaust(double x, double y, double dir, double spd){
		this(x, y, 0);
		setDirSpeed(dir, spd);
		setDepth(-901);
	}
	
	public void step(){
		xscale = (float)Calc.approach(xscale, goal, 12);
		goal = Calc.approach(goal, 0, 300);
		life++;
		if (life >= 120)
			destroy();
		vspeed -= .01;
		angle += vspeed;
		
		x += hspeed;
		y += vspeed;
	}
	
	public void render(){
		sprite.render(imageSingle, x + s.x, y + s.y, xscale, xscale, (float)(s.z / 4.0) + angle, ColorF.WHITE);
	}

}
